package com.akk.module.avs.service;

import com.akk.module.avs.entity.AvsApplyCard;
import com.akk.module.avs.entity.AvsApplyCardExample;
import com.akk.module.avs.mapper.AvsApplyCardMapper;
import com.akk.module.avs.mapper.dao.AvsApplyCardDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AvsApplyCardService {

    @Autowired
    private AvsApplyCardMapper applyCardMapper;

    @Autowired
    private AvsApplyCardExample applyCardExample;

    @Autowired
    private AvsApplyCardDao applyCardDao;

    public List<AvsApplyCard> queryAll(){
        applyCardExample.clear();
        applyCardExample.createCriteria().andCardStatusEqualTo(1);
        applyCardExample.setOrderByClause("card_index");
        return applyCardMapper.selectByExample(applyCardExample);
    }

    public List<AvsApplyCard> list(){
        applyCardExample.clear();
        applyCardExample.setOrderByClause("card_index");
        return applyCardMapper.selectByExample(applyCardExample);
    }

    public AvsApplyCard queryById(Long id){
        return applyCardMapper.selectByPrimaryKey(id);
    }

    public AvsApplyCard save(AvsApplyCard card){
        applyCardDao.insert(card);
        return card;
    }

    public void delete(Long id){
        applyCardMapper.deleteByPrimaryKey(id);
    }

    public void update(AvsApplyCard cardEntity) {
        applyCardMapper.updateByPrimaryKey(cardEntity);
    }
}
